package labox.innovation.gameserver.network.gameserverpackets;

import java.io.IOException;
import java.util.ArrayList;

/**
 * 向登陆服务器注册游戏服务器状态
 * 
 */
public class ServerStatus extends GameServerBasePacket {

	private ArrayList<Attribute> _attributes;

	public static final String[] STATUS_STRING = { "Down", "Good", "Normal", "Full", "Gm Only" };

	/*-----------------------服务器类型部分-------------------------------*/
	/**
	 * 时限服务器
	 */
	public static final int SERVER_LIST_CLOCK = 0x02;

	public static final int SERVER_LIST_SQUARE_BRACKET = 0x03;

	/**
	 * 测试服务器
	 */
	public static final int TEST_SERVER = 0x04;

	public static final int ON = 0x01;

	public static final int OFF = 0x00;

	/*-----------------------服务器状态部分-------------------------------*/

	/**
	 * 服务器状态标识符
	 */
	public static final int SERVER_LIST_STATUS = 0x01;

	public static final int STATUS_DOWN = 0x00;

	public static final int STATUS_GOOD = 0x01;

	public static final int STATUS_NORMAL = 0x02;

	public static final int STATUS_FULL = 0x03;

	public static final int STATUS_GM_ONLY = 0x04;

	/*-----------------------服务器状推荐部分-------------------------------*/

	public static final int SERVER_LIST_TYPE = 0x05;

	public static final int TYPE_NORMAL = 0x00;

	public static final int TYPE_NEW = 0x01;

	public static final int TYPE_RECOMMEND = 0x02;

	/*-----------------------服务器阈值部分-------------------------------*/

	/**
	 * 最大玩家上限
	 */
	public static final int MAX_PLAYERS = 0x06;

	class Attribute {
		public int id;

		public int value;

		Attribute(int pId, int pValue) {
			id = pId;
			value = pValue;
		}
	}

	public ServerStatus() {
		_attributes = new ArrayList<Attribute>();
	}

	public void addAttribute(int id, int value) {
		_attributes.add(new Attribute(id, value));
	}

	/* (non-Javadoc)
	 * @see net.sf.l2j.gameserver.gameserverpackets.GameServerBasePacket#getContent()
	 */
	@Override
	public byte[] getContent() throws IOException {
		writeByte(0x06);
		writeInt(_attributes.size());
		for (Attribute temp : _attributes) {
			writeInt(temp.id);
			writeInt(temp.value);
		}

		return getBytes();
	}

}